import easyocr
import cv2

# 1. 初始化阅读器（自动下载模型）
# reader = easyocr.Reader(['ch_sim', 'en'])
# 如果已经下载完了模型，可以直接指定模型位置
reader = easyocr.Reader(
    ['ch_sim', 'en'],
    model_storage_directory=r'C:\Users\systems\Desktop\仓库\shang-hai_ai\w2_图像认知与OpenCV\day 2\model',
    gpu=False,
    download_enabled=False  # 禁用在线下载
)

# 2. 读取图像并识别
img = cv2.imread("../images/text.png")
results = reader.readtext(img)

print(results)  # list []
plate_text = "".join([res[1] + "\n" for res in results])
print(plate_text)
